#ifndef __CAST_H__
#define __CAST_H__

#include <string>

template<class char_t> std::basic_string<char_t> basic_string_cast(const int& num)
{
	const char_t kNegative = sizeof(char_t) ? '-' : L'-';
	const char_t kZero = sizeof(char_t) ? '0' : L'0';
	
	char_t _itoa_buffer[16];
	std::basic_string<char_t> result;
	int t = num;
	int digit = -1;
	if (num < 0) {
		t = -num;
	}
	while (t > 0) {
		digit++;
		t /= 10;
	}
	if (digit < 0) {
		digit = 0;
	}
	t = num;
	if (num < 0) {
		_itoa_buffer[0] = kNegative;
		digit++;
		t = -num;
	}
	int count = digit + 1;
	do {
		_itoa_buffer[digit--] = kZero + (t % 10);
		t /= 10;
	} while (t > 0 && digit >= 0);
	result.assign(_itoa_buffer, count);
	return result;
}

std::string string_cast(const int& num);
std::wstring wstring_cast(const int& num);

std::wstring wstring_cast(const float& arg);

std::wstring cstr2wstr(const char *pcstr);

bool utf82unicode(const char* inStr, wchar_t* outStr);
bool utf82unicode(const char* inStr, const int inLen, wchar_t* outStr, int& outLen);

bool unicode2utf8(const wchar_t* inStr, char* outStr);
bool unicode2utf8(const wchar_t* inStr, const int inLen, char* outStr, int& outLen);


#endif //__CAST_H__
